import numpy as np
import random
all_video_file = '/home/sean/data/ILSVRC/ImageSets/VID/train_video_remove_no_object.txt'

video_num = 0.0
gt1000 = 0
_500to1000 = 0
_300to500 = 0
_100to300 = 0
_24to100 = 0
lt24 = 0
for line in open(all_video_file, 'r'):
    length = int(line.split(' ')[1])
    if length > 1000:
        gt1000 += 1
    elif length > 500:
        _500to1000 += 1
    elif length > 300:
        _300to500 += 1
    elif length > 100:
        _100to300 += 1
    elif length > 24:
        _24to100 += 1
    else:
        lt24 += 1
    video_num += 1
print('video_num:', video_num)
print('gt1000', gt1000, gt1000/video_num)
print('_500to1000:', _500to1000/video_num)
print('_300to500:', _300to500/video_num)
print('_100to300:', _100to300/video_num)
print('_24to100:', _24to100/video_num)
print('lt24:', lt24, lt24/video_num)

length = 445
seq = 16
# if length<seq:
#     repeat = seq // length
#     residue = seq % length
#     uniform_list.append()

# skip = int(length/seq)
# print(skip)
# uniform_list = list(range(0,length, skip))
# cast_list = random.sample(range(len(uniform_list)), len(uniform_list)-seq)
# select_list = [x for x in uniform_list[::random.sample([-1,1],1)[0]] if uniform_list.index(x) not in cast_list]

# print(uniform_list)
# print(cast_list)
# print(select_list)
# print(len(uniform_list), len(select_list))
start = np.random.randint(length - seq)
select_list = [x for x in range(start, start+16)]
print(select_list, len(select_list))